package com.hub.db.service;

import com.hub.db.entity.User;
import com.hub.db.repository.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ author 令狐冲
 * @ date & time 2025/2/24 8:53
 */

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public void createUser(Long userId, String userName) {
        User user = new User();
        user.setUserId(userId);
        user.setUserName(userName);
        userMapper.insert(user);
        System.out.println("Inserted user: " + userName);
    }

    public User getUserById(Long userId) {
        return userMapper.selectById(userId);
    }
}
